import React,{useState} from 'react'
import { Container } from './style'



export default function ShoppingCartBottom(props) {
  const {allSelect,isAllSelect,selectGoods,settleElement}=props
  console.log(isAllSelect);
  const [sum,setSum] = useState(0);
  const getsum = () => {
    console.log('getSum 开始执行了');
    let sum = 0;
    selectGoods.map((item)=>{
      if(item.isSelect == true){
        sum = sum + item.price*item.count 
        console.log(sum);
      }
    })
    return sum
  }

  return (
    <Container>
        <div className="first">
           <input type='checkbox' id='one' onChange={allSelect} checked={isAllSelect}/> 
           <label className='label' htmlFor='one'>全选</label>
        </div>
        <div className="box third">
            <div className="third1">总计:</div>
            <div className="third2">￥{getsum()}</div>
        </div>
        <div className="box forth" onClick={settleElement.bind(null,sum)}>结算</div>
    </Container>
  )
}